<?php defined('SYSPATH') or die('No direct script access.');
 
class Model_Hotels extends Model {

	 protected $_table = 'hotels';

    public function getAll() {
        $sql = "select * from hotels";
        return DB::query(Database::SELECT, $sql)->execute()->as_array();
    }

    public function getItems($city_to, $package_id) {
    	if(!empty($package_id)){
    		$sql = "select hotels.* from hotels, package_hotels WHERE package_hotels.hotel_id = hotels.id AND package_hotels.package_id = :package_id ";
    		return DB::query(Database::SELECT, $sql)->parameters(array(':package_id' => $package_id))->execute()->as_array();
    	}else{
    		$query = DB::select()
				->from($this->_table)
				->where('parent','=',$city_to)
				->execute();
			return $query;
    	}
    }

}